import 'dart:math';

import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';

class SuddenlyRichLogic extends GetxController {
  // 数量
  var count = 1.obs;

  void increment() => count++;

  // 生成暴富
  void generateRich() {
    var list = [];
    // 生成双色球号码
    for (var i = 0; i < count.value; i++) {
      final numbers = _generateLotteryNumbers();
      list.add(numbers);
    }
    String result = list.toString();
    Clipboard.setData(ClipboardData(text: result));
    Fluttertoast.showToast(msg: "GO Go Go!!!");
  }

  // 生成双色球彩票号码
  String _generateLotteryNumbers() {
    final random = Random();
    final redBalls = <int>{};
    while (redBalls.length < 6) {
      redBalls.add(random.nextInt(33) + 1);
    }
    var redList = redBalls.toList();
    redList.sort();
    final blueBall = random.nextInt(16) + 1;
    return '红球: $redList, 蓝球: $blueBall \n';
  }
}
